package bTree.LeetCode;

import javax.swing.tree.TreeNode;

public class 计算二叉树布尔的值 {
    public boolean evaluateTree(TreeNode root) {
        return backToll(root);
    }

    private boolean backToll(TreeNode root) {
        if (root.left==null&&root.right==null){
            return root.val == 1;
        }
        boolean left=backToll(root.left);
        boolean right=backToll(root.right);
        return root.val==3?left&&right:left||right;
    }
}